package com.wlyuan.open.remote.facade.translator;

import com.wlyuan.core.domain.MappingIds;
import com.wlyuan.open.remote.facade.User;
import com.wlyuan.user.dto.UserDetailVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author lijing
 */
public class UserTranslator {
    @Mapper(uses = {
            MappingIds.class
    })
    public interface Translator {

        @Mappings({
                @Mapping(source = "tenantName", target = "name"),
                @Mapping(source = "tenantCode", target = "code"),
                @Mapping(source = "tenantAlias", target = "alias"),
                @Mapping(source = "tenantStatus", target = "status"),
                @Mapping(source = "tenantNameStatus", target = "statusName"),
        })
        User translate(UserDetailVO source);

    }

    private static final Translator TRANSLATOR = Mappers.getMapper(Translator.class);

    public static User translate(UserDetailVO source) {
        return TRANSLATOR.translate(source);
    }

}
